(Vinvocation_name): New variable.
(init_cmdargs): Set it.
(syms_of_emacs): defsubr Finvocation_name, staticpro and
initialize Vinvocation_name.
* lisp.h (Vinvocation_name): New extern declaration.
* xterm.c (invocation_name): Variable deleted; use
Vinvocation_name now.
(x_text_icon, x_term_init): Use Vinvocation_name now instead of
invocation_name.
(x_term_init): Don't initialize invocation_name.
(syms_of_xterm): Don't initialize or staticpro invocation_name.
* xfns.c (invocation_name): Remove extern declaration for this.
[HAVE_X11] (Fx_get_resource): Use Vinvocation_name now instead of
invocation_name.
[not HAVE_X11] (Fx_get_default): Same.
/* Command line args from shell, as list of strings */
Lisp_Object Vcommand_line_args;
+/* The name under which Emacs was invoked, with any leading directory
+ names discarded. */
+Lisp_Object Vinvocation_name;
+
/* Hook run by `kill-emacs' before it does really anything. */
Lisp_Object Vkill_emacs_hook;
{
register int i;
+ Vinvocation_name = Ffile_name_nondirectory (argv[0]);
+
Vcommand_line_args = Qnil;
for (i = argc - 1; i >= 0; i--)
= Fcons (build_string (argv[i]), Vcommand_line_args);
}
}
+
+DEFUN ("invocation-name", Finvocation_name, Sinvocation_name, 0, 0, 0,
+ "Return the program name that was used to run Emacs.\n\
+Any directory names are omitted.")
+ ()
+{
+ return Fcopy_sequence (Vinvocation_name);
+}
+
\f
#ifdef VMS
#ifdef LINK_CRTL_SHARE
defsubr (&Skill_emacs);
+ defsubr (&Sinvocation_name);
+
DEFVAR_LISP ("command-line-args", &Vcommand_line_args,
"Args passed by shell to Emacs, as a list of strings.");
and only if the Emacs executable is installed with setuid to permit\n\
it to change priority. (Emacs sets its uid back to the real uid.)");
emacs_priority = 0;
+
+ staticpro (&Vinvocation_name);
+ Vinvocation_name = Qnil;
}
/* defined in emacs.c */
extern Lisp_Object decode_env_path ();
+extern Lisp_Object Vinvocation_name;
void shut_down_emacs ( /* int signal */ );
/* Nonzero means don't do interactive redisplay and don't change tty modes */
extern int noninteractive;
/* Title name and application name for X stuff. */
extern char *x_id_name;
-extern Lisp_Object invocation_name;
/* The background and shape of the mouse pointer, and shape when not
over text or in the modeline. */
{
/* Allocate space for the components, the dots which separate them,
and the final '\0'. */
- name_key = (char *) alloca (XSTRING (invocation_name)->size
+ name_key = (char *) alloca (XSTRING (Vinvocation_name)->size
+ XSTRING (attribute)->size
+ 2);
class_key = (char *) alloca ((sizeof (EMACS_CLASS) - 1)
+ 2);
sprintf (name_key, "%s.%s",
- XSTRING (invocation_name)->data,
+ XSTRING (Vinvocation_name)->data,
XSTRING (attribute)->data);
sprintf (class_key, "%s.%s",
EMACS_CLASS,
}
else
{
- name_key = (char *) alloca (XSTRING (invocation_name)->size
+ name_key = (char *) alloca (XSTRING (Vinvocation_name)->size
+ XSTRING (component)->size
+ XSTRING (attribute)->size
+ 3);
+ 3);
sprintf (name_key, "%s.%s.%s",
- XSTRING (invocation_name)->data,
+ XSTRING (Vinvocation_name)->data,
XSTRING (component)->data,
XSTRING (attribute)->data);
sprintf (class_key, "%s.%s",
CHECK_STRING (arg, 1);
value = (unsigned char *) XGetDefault (XDISPLAY
- XSTRING (invocation_name)->data,
+ XSTRING (Vinvocation_name)->data,
XSTRING (arg)->data);
if (value == 0)
/* Try reversing last two args, in case this is the buggy version of X. */
value = (unsigned char *) XGetDefault (XDISPLAY
XSTRING (arg)->data,
- XSTRING (invocation_name)->data);
+ XSTRING (Vinvocation_name)->data);
if (value != 0)
return build_string (value);
else
extern Lisp_Object Vcommand_line_args;
char *hostname, *x_id_name;
-Lisp_Object invocation_name;
/* This is the X connection that we are using. */
if (icon_font_info == 0)
icon_font_info
= XGetFont (XGetDefault (XDISPLAY
- (char *) XSTRING (invocation_name)->data,
+ (char *) XSTRING (Vinvocation_name)->data,
"BodyFont"));
if (f->display.x->icon_desc)
XSetAfterFunction (x_current_display, x_trace_wire);
#endif /* ! 0 */
- invocation_name = Ffile_name_nondirectory (Fcar (Vcommand_line_args));
-
/* Try to get the host name; if the buffer is too short, try
again. Apparently, the only indication gethostname gives of
whether the buffer was large enough is the presence or absence
hostname_size <<= 1;
hostname = (char *) xrealloc (hostname, hostname_size);
}
- x_id_name = (char *) xmalloc (XSTRING (invocation_name)->size
+ x_id_name = (char *) xmalloc (XSTRING (Vinvocation_name)->size
+ strlen (hostname)
+ 2);
- sprintf (x_id_name, "%s@%s", XSTRING (invocation_name)->data, hostname);
+ sprintf (x_id_name, "%s@%s", XSTRING (Vinvocation_name)->data, hostname);
}
/* Figure out which modifier bits mean what. */
void
syms_of_xterm ()
{
- staticpro (&invocation_name);
- invocation_name = Qnil;
-
staticpro (&last_mouse_scroll_bar);
}
#endif /* ! defined (HAVE_X11) */